﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DigitalAnts.App_Code.BAL.Entities;
using DigitalAnts.App_Code.BAL.Components;
using System.Data;
using BAL.Components;
using BAL.Entities;

namespace DigitalAnts
{
    public partial class FeedBack : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                doLoadUserProfile();
            }
        }

        public void doLoadUserProfile()
        {
            if (HttpContext.Current.Session["Logged"] != null)
            {
                if (HttpContext.Current.Session["Logged"].Equals(true))
                {   
                    clsUser obj = new clsUser();
                    obj.UserID = Convert.ToInt32(Session["UserID"]);
                    DataTable dt = clsUserBAL.doGetUserByID(obj);
                    if (dt.Rows.Count > 0)
                    {
                        DataRow dr = dt.Rows[0];
                        this.txtFullName.Text = dr["colFirstName"].ToString() + " " + dr["colLastName"].ToString();
                        this.txtEmail.Text = dr["colEmail"].ToString();
                        this.txtPhone.Text = "0" + dr["colCellPhone"].ToString();
                    }
                }
            }
        }

        protected void btSubmit_Click(object sender, EventArgs e)
        {
            clsFeedback obj = new clsFeedback();
            obj.Email = this.txtEmail.Text;
            obj.Content = this.txtContent.Text;
            obj.Detail = this.txtTitle.Text;
            obj.Fullname = this.txtFullName.Text;
            obj.Phone = Convert.ToInt32(this.txtPhone.Text);

            clsFeedbackBAL.doAddFeedback(obj);
        }
    }
}